<html xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" >  

    <ui:composition template="layout.xhtml">
        <ui:define name="corpo">
            <h:form id="buscar_form" acceptcharset="utf-8"> 
                <div id="breadcrumb">
                    <p:commandLink  actionListener="#{managerIndex.redirect('index.xhtml')}" value="Inicio" update="@form" immediate="true"/> >
                    <p:commandLink  actionListener="#{managerIndex.redirect('indexSelo.xhtml')}" value="Selos" update="@form" immediate="true"/> >
                    <p:commandLink  value="Pesquisar Entrada Selo" update="@form" immediate="true"/>
                </div>
                <p:panel header="Pesquisar Entrada selo">
                    <p:messages showDetail="true"  id="msg" /> 
                    <fieldset>
                        <legend>Filtros</legend>    
                        <h:panelGrid columns="2"  border="0" styleClass="textAlignRight" columnClasses="textAlignRight"> 
                            
                            <h:outputLabel value="N° Nota :"/>
                            <p:inputText  id="notaselo" value="#{managerVisualizarEntradaSelo.numeroNota}" size="24"/>

                            <h:outputLabel value="Fornecedor: "/>
                            <p:autoComplete id="fornecedor" 
                                            value="#{managerVisualizarEntradaSelo.fornecedor}" 
                                            completeMethod="#{managerFornecedor.completeFornecedor}"  
                                            var="p" itemLabel="#{p.nome}" itemValue="#{p}"
                                            converter="fornecedorConverter" forceSelection="true"
                                            converterMessage="Erro, verifique o Fornecedor"
                                            minQueryLength="3" dropdown="true" size="20" scrollHeight="200"> 
                                    <p:ajax event="itemSelect" listener="#{managerEntrada.handleSelect}"/>                                        
                            </p:autoComplete>

                            <h:outputLabel value="Data da Nota: " /> 
                            <p:calendar value="#{managerVisualizarEntradaSelo.entradaSelo.dataNote}" label="Data" 
                                            size="20"  id="data_nota" mode="popup" showOn="both" pattern="dd/MM/yyyy" />


                        </h:panelGrid>    
                        
                    </fieldset>
                    <div class="buttonAction">
                            <p:commandButton process="@form" icon="ui-icon-search"
                                             action="#{managerVisualizarEntradaSelo.buscar()}" 
                                             value="Buscar" update="entradaSeloTable"/>
                            
                              <p:commandButton id="limpar" icon="ui-icon-arrowreturnthick-1-w" 
                                         value="Cancelar" 
                                         actionListener="#{managerIndex.redirect('indexSelo.xhtml')}" 
                                         immediate="true" />
                              <p:ajaxStatus style="width:16px;height:16px;" id="ajaxStatusPanel">  
                                <f:facet name="start">  
                                    <h:graphicImage value="/media/img/loading.gif" />  
                                </f:facet>  

                                <f:facet name="complete">  
                                    <h:outputText value="" />  
                                </f:facet>  
                            </p:ajaxStatus>
                        </div>
                    
                    <p:dataTable id="entradaSeloTable" var="entradaSelo" value="#{managerVisualizarEntradaSelo.entradaSelos}" 
                                 paginator="true" rows="5"
                                 paginatorPosition="bottom"
                                 emptyMessage="Nenhum registro encontrado"
                                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"  
                                 rowsPerPageTemplate="5,10,15">     
                        <f:facet name="header">  
                            Resultado Entrada Selo
                        </f:facet>
                        <p:column style="width:400px;" headerText="Numero da nota">  
                             
                            <h:outputText value="#{entradaSelo.numeroNota}" />  
                        </p:column>
                        <p:column headerText="Fornecedor">  
                            <h:outputText value="#{entradaSelo.fornecedor.nome}" />  
                        </p:column>
                        <p:column headerText="Data da nota">  
                            <h:outputText  value="#{entradaSelo.dataNote}" >
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </h:outputText>
                        </p:column>
                       
                        <p:column style="width:64px;" headerText="Opções">
                            <p:commandButton  icon="editar"  actionListener="#{managerEditarEntradaSelo.redirect('editarEntradaSelo.xhtml', entradaSelo)}" update="@form"/> 
                            <p:commandButton  icon="view" actionListener="#{managerVisualizarEntradaSelo.redirect('visualizarEntradaSelo.xhtml', entradaSelo)}" update="@form"/>   

                        </p:column>  

                    </p:dataTable>  

                </p:panel>
                <br/>
            </h:form>
        </ui:define>
    </ui:composition>
</html>